/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2012/07/11
* File: SkyboxSceneNode.h
* Blog: http://www.cnblogs.com/zengqh/
**/

#ifndef SkyboxSceneNode_h__
#define SkyboxSceneNode_h__

#include "../Core/Core.h"
#include "../Core/Declare.h"
#include "SceneNode.h"
#include "../RenderSystem/MaterialData.h"
#include "../RenderSystem/EffectService.h"

class SkyboxEffectiveService;
class SkyboxSceneNode : public SceneNode
{
public:
	SkyboxSceneNode(
		SceneNode* parent, 
		SceneManager* scene_mgr, 
		s32 id = -1,
		s32 type = 0,
		Texture* top = NULL,
		Texture* bottom = NULL,
		Texture* left = NULL,
		Texture* right = NULL,
		Texture* front = NULL,
		Texture* back = NULL);

	~SkyboxSceneNode();

	void render();

protected:
	void initMaterial();
	void initGraphicsBuffer();
	void initEffectService();

protected:
	Texture*						_texture_list[6];
	MaterialData					_sky_box_material[6];
	GraphicsBuffer*					_vbo_buffer;
	GraphicsBuffer*					_idx_buffer;
	SkyboxEffectiveService*			_skybox_effect_service;
};

class SkyboxEffectiveService : public EffectService
{
public:
	SkyboxEffectiveService(Effect* effect, RenderSystem* render_system);
	~SkyboxEffectiveService();

	void applyMatrix();
	void applyMaterial();
	void applyLight();
	void active();

	s32  getVertexHandle();
	s32  getNormalHandle();
	s32  getTexcoordHandle();
	s32  getColorHandle();
protected:
	RenderSystem*		_render_system;
};

#endif    /* SkyboxSceneNode_h__ */